package com.randi.system.domain.entity.sysDict;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.randi.common.annotation.Excel;
import com.randi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.Transient;

import javax.validation.constraints.NotBlank;

/**
 * @author ziye
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("sys_dict")
@ApiModel(value = "SysDict", description = "字典信息")
public class SysDict extends BaseEntity {

    @TableId(value = "dict_id", type = IdType.AUTO)
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "字典ID")
    @Excel(name = "字典ID")
    private Long dictId;

    @NotBlank(message = "字典名称不能为空")
    @TableField(value = "`dict_name`")
    @ApiModelProperty(value = "字典名称")
    @Excel(name = "字典名称")
    private String dictName;

    @NotBlank(message = "字典类型不能为空")
    @TableField(value = "`dict_type`")
    @ApiModelProperty(value = "字典类型")
    @Excel(name = "字典类型")
    private String dictType;

    @Transient
    public String getKey() {
        return this.dictId == null ? "" : this.dictId.toString();
    }

    @Transient
    public String getStatusName() {
        return getStatus() == null || getStatus() == 0 ? "正常" : "停用";
    }


}
